define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Luckydraw,GoPage, $stateParams) {
		//查看抽奖
		$scope.onshow_luckydrawdetail = function(){
			GoPage.go_states("luckydrawdetail");
		}

		//接收参数
		$scope.act_id = $stateParams.id;
		$scope.draw_type = 1;//默认是自动抽奖
	   $scope.init_data = function(draw_type) {
		  Luckydraw.connectagency($scope.act_id, $scope.draw_type, function(data) {
				$scope.list = data;
			});
		}
 		$scope.init_data($scope.draw_type); //必须在定义之后
 	
		$scope.getDrawType = function(value){//自动
			$scope.draw_type = value;//$scope.draw_type变量主要是判断样式用
			$scope.init_data($scope.draw_type);
		}
		
		//删除
		$scope.delete_act = function(id) {
			var i = 0;
			var n = -1;
			for(var o in $scope.list.member){
				if($scope.list.member[o].member_id == id){
					n = i;
					break;
				}
				i++;
			}
			if(n != -1){
				$scope.list.member.splice(n,1);
			}
		}
	 
	}

	controller.$inject = ['$scope', 'Luckydraw','GoPage','$stateParams'];
	
	return app.registerController("luckydrawctrl",controller);
});